package com.example.rabbit.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 开启swagger2
 *
 * @Author ifredomvip@gmail.com
 * @Date 2022/8/9 17:30
 * @Version 1.0.0
 * @Description
 **/
@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket generatorDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApi")
                .apiInfo(buildApiInfo())
                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.example.rabbit.controller"))
//                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo buildApiInfo() {
        return new ApiInfoBuilder()
                .title("rabbit-springboot接口文档")
                .description("springboot集成rabbitMQ")
                .version("1.0.0")
                .contact(new Contact("ifredom", "www.ifredom.com", "1950735817@qq.com"))
                .build();
    }

}
